<template>
  <div class="main-content">
    <p-s-i-list-head
      :search.sync="search"
      :psi-type="psiType"
      title="入库管理"
      placeholder="请输入入库名称/手机/电话"
      main-title="新建入库"
      @on-handle="listHeadHandle"
      @on-search="psiSearch"
      @on-export="exportInfos"/>
    <div
      v-empty=""
      xs-empty-icon="nopermission"
      xs-empty-text="暂无权限"
      class="psi-container">
      <p-s-i-table-head
        ref="psiTableHead"
        :psi-type="psiType"
        @filter="handleFilter"
        @exportData="exportData"
        @handle="handleHandle"
        @scene="handleScene"/>
      <el-table
        v-loading="loading"
        id="psi-table"
        :data="list"
        :height="tableHeight"
        :cell-style="cellStyle"
        class="n-table--border"
        stripe
        border
        highlight-current-row
        style="width: 100%"
        @row-click="handleRowClick"
        @sort-change="sortChange"
        @header-dragend="handleHeaderDragend"
        @selection-change="handleSelectionChange">
        <el-table-column
          show-overflow-tooltip
          type="selection"
          align="center"
          width="55"/>
        <el-table-column
          v-for="(item, index) in fieldList"
          :key="index"
          :fixed="index==0"
          :prop="item.prop"
          :label="item.label"
          :width="item.width"
          :formatter="fieldFormatter"
          sortable="custom"
          show-overflow-tooltip>
          <template
            slot="header"
            slot-scope="scope">
            <span class="table-head-name" :title="scope.column.label">{{ scope.column.label }}</span>
          </template>
        </el-table-column>
        <el-table-column
          :resizable="false"
          show-overflow-tooltip
          prop="checkStatus"
          label="状态"
          min-width="100"
          fixed="right">
          <template slot-scope="scope">
            <div
              :style="getStatusStyle(scope.row.checkStatus)"
              class="status_button">
              {{ getStatusName(scope.row.checkStatus) }}
            </div>
          </template>
        </el-table-column>
        <el-table-column
          fixed="right"
          width="36">
          <template
            slot="header" slot-scope="{}">
            <i class="el-icon-setting table-set" @click="handleTableSet"></i>
          </template>
        </el-table-column>
      </el-table>
      <div class="p-contianer">
        <el-pagination
          :current-page="currentPage"
          :page-sizes="pageSizes"
          :page-size.sync="pageSize"
          :total="total"
          class="p-bar"
          layout="total, sizes, prev, pager, next, jumper"
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"/>
      </div>
    </div>
    <fields-set
      :psi-type="psiType"
      :dialog-visible.sync="showFieldSet"
      @set-success="setSave"/>
  </div>
</template>
<script>
import table from '../../psimanagement/mixins/table'
import PSIListHead from '../components/PSIListHead'
import PSITableHead from '../components/PSITableHead'
export default {
  name: 'enterIndex',
  components: { PSITableHead, PSIListHead },
  mixins: [table],
  data() {
    return {
      psiType: 'enter-storage'
    }
  },
  computed: {},
  mounted() {},
  methods: {
    /** 通过回调控制style */
    cellStyle({ row, column, rowIndex, columnIndex }) {
      if (column.property === 'leadsName') {
        return { color: '#3E84E9', cursor: 'pointer' }
      } else {
        return ''
      }
    }
  }
}
</script>
<style lang="scss" scoped>
  @import '../../psimanagement/styles/table.scss';
</style>
